package cn.iocoder.yudao.module.system.controller.admin.mini.other.turnInfo.dal.mysql.turninfo;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.controller.admin.mini.other.turnInfo.controller.admin.turninfo.vo.TurnInfoExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.mini.other.turnInfo.controller.admin.turninfo.vo.TurnInfoPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.mini.other.turnInfo.dal.dataobject.turninfo.TurnInfoDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * 转盘发送记录 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface TurnInfoMapper extends BaseMapperX<TurnInfoDO> {

    @Select("select count(1) from qd_turn_info where uid=#{uid}")
    Integer findByUid(Integer uid);


    default PageResult<TurnInfoDO> selectPage(TurnInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TurnInfoDO>()
                .betweenIfPresent(TurnInfoDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(TurnInfoDO::getTid, reqVO.getTid())
                .likeIfPresent(TurnInfoDO::getName, reqVO.getName())
                .likeIfPresent(TurnInfoDO::getPhone, reqVO.getPhone())
                .likeIfPresent(TurnInfoDO::getMail, reqVO.getMail())
                .eqIfPresent(TurnInfoDO::getUid, reqVO.getUid())
                .eqIfPresent(TurnInfoDO::getStatus, reqVO.getStatus())
                .orderByDesc(TurnInfoDO::getId));
    }

    default List<TurnInfoDO> selectList(TurnInfoExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<TurnInfoDO>()
                .betweenIfPresent(TurnInfoDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(TurnInfoDO::getTid, reqVO.getTid())
                .likeIfPresent(TurnInfoDO::getName, reqVO.getName())
                .eqIfPresent(TurnInfoDO::getUid, reqVO.getUid())
                .eqIfPresent(TurnInfoDO::getStatus, reqVO.getStatus())
                .orderByDesc(TurnInfoDO::getId));
    }

}
